var _oActive;


function InsertDataField()
{
var oArgs = new Object();

oArgs.Xml	= oObjectsXml;
oArgs.Text	= null;

var oRetVal = openStdDlg(prependOrgName("/Tools/EmailTemplateEditor/Dialogs/datafieldproperties.aspx"), oArgs, 550, 450);

if (!IsNull(oRetVal) && oRetVal.length == 2)
{
if(document.activeElement.id != "SubjectEditor" && document.activeElement.id != "TemplateEditor")
{
TemplateEditor.focus();
}

var sId = "df" + LocalDateTimeNow().getTime();
document.execCommand("InsertButton", null, sId);
var oTemp = document.all(sId);
var oDataSlug = document.createElement("SPAN");
oDataSlug.tabIndex = -1;
oTemp.replaceNode(oDataSlug);
with (oDataSlug)
{
className			= "dataslug";
oDataSlug.value		= oRetVal[0];
innerText			= oRetVal[1];
contentEditable		= false;

onbeforeeditfocus = function() { return false;};
click();
}

if(document.activeElement.id == "SubjectEditor")
{
checkForSubjectDataSlugs();
}
}
}


function DeleteDataField()
{
if (_oActive)
{
_oActive.removeNode(true);

_oActive = null;
}

if(document.activeElement.id == "SubjectEditor")
{
checkForSubjectDataSlugs();
}
}


function UpdateDataField()
{
if (_oActive)
{



if (_oActive.innerText == "")
{
DeleteDataField();
InsertDataField();
}
else
{
var oArgs = new Object();

oArgs.Xml	= oObjectsXml;
oArgs.Text	= _oActive.value;

var oRetVal = openStdDlg(prependOrgName("/Tools/EmailTemplateEditor/Dialogs/datafieldproperties.aspx"), oArgs, 550, 450);

if (!IsNull(oRetVal) && oRetVal.length == 2)
{
_oActive.value = oRetVal[0];
_oActive.innerText = oRetVal[1];
}
}
}
else
{
InsertDataField();
}
}

function UnsubscribeLink()
{

var sText = document.selection.createRange();











document.execCommand("CreateLink", false, "mailto:[Run_Time_Address]?subject=[Run_Time_Subject]");
}